﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using VSA.Entity;
namespace VSA.BLL
{
	/// <summary>
	/// t_Activity
	/// </summary>
	public partial class ActivityBLL
	{
		private static readonly VSA.DAL.ActivityDAL dal=new VSA.DAL.ActivityDAL();
        public ActivityBLL()
		{}
		#region  Method
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int Did)
		{
			return dal.Exists(Did);
		}

        public static bool Contains(string value)
        {
            return dal.Exists(value);
        }

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public static bool Add(VSA.Entity.Activity model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public static bool Update(VSA.Entity.Activity model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public static bool Delete(int Did)
		{
			
			return dal.Delete(Did);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string Didlist )
		{
            return false;
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public VSA.Entity.Activity GetModel(int Did)
		{
			
			return dal.GetModel(Did);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public VSA.Entity.Activity GetModelByCache(int Did)
		{
			
			string CacheKey = "t_ActivityModel-" + Did;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(Did);
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (VSA.Entity.Activity)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public static DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public static List<VSA.Entity.Activity> GetModelList(string strWhere)
		{
            return dal.GetListArray(strWhere);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<VSA.Entity.Activity> DataTableToList(DataTable dt)
		{
			List<VSA.Entity.Activity> modelList = new List<VSA.Entity.Activity>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				VSA.Entity.Activity model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new VSA.Entity.Activity();
					if(dt.Rows[n]["Did"].ToString()!="")
					{
						model.Did=int.Parse(dt.Rows[n]["Did"].ToString());
					}
					model.ActivityContent=dt.Rows[n]["ActivityContent"].ToString();
					model.Note=dt.Rows[n]["Note"].ToString();
					if(dt.Rows[n]["CreateDate"].ToString()!="")
					{
						model.CreateDate=DateTime.Parse(dt.Rows[n]["CreateDate"].ToString());
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

